--
-- @Author:      feilong
-- @DateTime:    2019-11-29 14:02:03
-- @Description: 游戏对象
local skynet = require("skynet")
local GameDef = require("GameDef")

local Game = class("Game")

--构造函数
function Game:ctor(table_id)
	self.game_id = math.floor(table_id / 10000) --游戏id
	self.table_id = table_id --桌子id
	self.service_name = GameDef.service_name[self.game_id]
	self.service = nil
	self.node_message = global.node_message
end

function Game:getGameId()
	return self.game_id
end
function Game:setGameId(id)
	self.game_id = id
end
function Game:getTableId()
	return self.table_id
end
function Game:setTableId(id)
	self.table_id = id
end
function Game:getService()
	return self.service
end
function Game:setService(service)
	self.service = service
end

function Game:start()
	if not self.service then 
		self.service = skynet.newservice(self.service_name) 
	end
	self.node_message:sendService(self.service, "start")
end
function Game:stop()
	if not self.service then 
		return 
	end
	self.node_message:sendService(self.service, "stop")
	self.service = nil
end


return Game